package com.gateway.pay.channel.dto;

import lombok.Getter;

@Getter
public enum ErrorCode {

    SUCCESS("200", "success", "成功"),
    FAIL("0001", "fail","失败"),
    ERROR("500", "error","服务器错误"),
    THIRD_ERROR("50002","error","三方错误");



    private String code;

    private String info;

    private String desc;

    ErrorCode(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    ErrorCode(String code, String info, String desc) {
        this.code = code;
        this.info = info;
        this.desc = desc;
    }

    public static ErrorCode getErrorCode(String info) {
        for (ErrorCode errorCode : ErrorCode.values()) {
            if (StringUtils.isNotBlank(info)
                    && errorCode != null
                    && StringUtils.isNotBlank(errorCode.getInfo())
                    && errorCode.getInfo().equalsIgnoreCase(info)) {
                return errorCode;
            }
        }
        return null;
    }
}
